// Fill out your copyright notice in the Description page of Project Settings.


#include "TapDBLibrary.h"

#if PLATFORM_ANDROID
#include "TapDBJNI.h"
#endif

DEFINE_LOG_CATEGORY_STATIC(LogTapDB, Display, All);

void UTapDBLibrary::SetUser(FString UserId)
{
#if PLATFORM_ANDROID
    TapDB::jni_setUser(TCHAR_TO_UTF8(*UserId));
#else 
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBSetUser(%s)"), *UserId);
#endif
}

void UTapDBLibrary::SetName(FString Name)
{    
#if PLATFORM_ANDROID
    TapDB::jni_setName(TCHAR_TO_UTF8(*Name));
#else
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBSetName(%s)"), *Name);
#endif
}

void UTapDBLibrary::SetLevel(int32 Level)
{
#if PLATFORM_ANDROID
    TapDB::jni_setLevel(Level);
#else
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBSetLevel(%d)"), Level);
#endif
}

void UTapDBLibrary::SetServer(FString Server)
{
#if PLATFORM_ANDROID
    TapDB::jni_setServer(TCHAR_TO_UTF8(*Server));
#else
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBSetServer(%s)"), *Server); 
#endif
}

void UTapDBLibrary::OnCharge(FString OrderId, FString Product, int32 amount, FString CurrencyType, FString Payment)
{   
#if PLATFORM_ANDROID
    TapDB::jni_onCharge(TCHAR_TO_UTF8(*OrderId), TCHAR_TO_UTF8(*Product), amount, TCHAR_TO_UTF8(*CurrencyType), TCHAR_TO_UTF8(*Payment));
#else
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBOnCharge(%s,%s,%d,%s,%s)"), *OrderId, *Product, amount, *CurrencyType, *Payment);
#endif
}

void UTapDBLibrary::OnEvent(FString EventCode, FString Properties)
{
#if PLATFORM_ANDROID
    TapDB::jni_onEvent(TCHAR_TO_UTF8(*EventCode), TCHAR_TO_UTF8 (*Properties));
#else
    UE_LOG(LogTapDB, Display, TEXT("UTapDBLibrary::TapDBOnEvent(%s,%s)"), *EventCode, *Properties);
#endif
}